@REM 工程配置文件
@echo off

setlocal enabledelayedexpansion

set output_file=build\source_file.mk

if not exist "build" (
	mkdir build
)

if not exist "build\objs" (
	mkdir build\objs
)

echo  #This file is maked by run configure.bat.>%output_file%

for /f "delims=" %%a in (source_file.prj) do (
	set ttt=%%a
	set head=!ttt:~,2!
	if !head! == ^/^/ (
		echo //
	) else (
		if %%~xa == .c (
			echo !ttt!
			echo OBJS += build/objs/%%~na.o>>%output_file%
			echo build/objs/%%~na.o : $^(ROOT_DIR^)/%%a>>%output_file%
			echo 	$^(CC_PREFIX^)$^(CC^) $^(C_FLAGS^) -c -o "$@" "$<">>%output_file%
		) else (
			if %%~xa == .s (
				echo OBJS += build/objs/%%~na.o>>%output_file%
				echo build/objs/%%~na.o : $^(ROOT_DIR^)/%%a>>%output_file%
				echo 	$^(CC_PREFIX^)$^(AS^) $^(S_FLAGS^) -c -o "$@" "$<">>%output_file%
			) else (
				if %%~xa == .S (
					echo OBJS += build/objs/%%~na.o>>%output_file%
					echo build/objs/%%~na.o : $^(ROOT_DIR^)/%%a>>%output_file%
					echo 	$^(CC_PREFIX^)$^(AS^) $^(S_FLAGS^) -c -o "$@" "$<">>%output_file%
				) else (								
					set "ttt=!ttt:/*.h=.o!"
					echo C_FLAGS += -I$^(ROOT_DIR^)/!ttt!>>%output_file%
				)
			)
		)
	)
)

set project_name = 0
call:get_name %cd% rst
echo %project_name%

@REM for /f "delims=" %%a in (../../.vscode/tasks.json) do (
@REM 	echo %%a
@REM )

:get_name
set project_name=%~n1
goto:eof

@echo on

